//https://www.nowcoder.com/practice/acead2f4c28c401889915da98ecdc6bf?tpId=230
#include <iostream>
#include <vector>
using namespace std;
 
int main() 
{
    int n = 0, q = 0;
    cin >> n >> q;
    vector<int> arr(n + 1, 0);
    for (int i = 1; i <= n; i++) // 读取数据
    {
        cin >> arr[i];
    }
    vector<long long> dp(n + 1, 0); // 防溢出
    for (int i = 1; i <= n; i++) // 处理前缀和数组
    {
        dp[i] = dp[i - 1] + arr[i];
    }
    int left = 0, right = 0;
    while (q--) // 计算区间和
    {
        cin >> left >> right;
        cout << dp[right] - dp[left - 1]<< endl;
    }
    return 0;
}